import Mock from 'mockjs'

// 定义对象并赋值给变量
const menuData = {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body)
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === '13411111111' && password === '246810') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/LayoutPage/home',
              name: 'home',
              label: '首页数据',
              icon: 'HomeOutlined',
              url: 'LayoutPage/home'
            },
            {
              path: '/LayoutPage/reusable',
              name: 'ReusableComponent',
              label: '表格增删改查',
              icon: 'ShopOutlined',
              url: 'LayoutPage/reusable'
            },
            {
              path: '/LayoutPage/moibel',
              name: 'moibelComponent',
              label: '移动端组件',
              icon: 'UserOutlined',
              url: 'LayoutPage/moibel'
            },
            {
              path: '/LayoutPage/other',
              label: '其他管理',
              icon: 'GoldOutlined',
              children: [
                {
                  path: '/LayoutPage/other/pageOne',
                  name: 'page1',
                  label: '静态评论列表',
                  icon: 'GoldOutlined',
                  url: 'LayoutPage/other/pageOne'
                },
                {
                  path: '/LayoutPage/other/pageTwo',
                  name: 'page2',
                  label: '页面2',
                  icon: 'GoldOutlined',
                  url: 'LayoutPage/other/pageTwo'
                },
                {
                  path: '/LayoutPage/other/pageThree',
                  name: 'page3',
                  label: '页面3',
                  icon: 'GoldOutlined',
                  url: 'LayoutPage/other/pageThree'
                }
              ]
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else if (username === 'xiaoxiao' && password === 'xiaoxiao') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/LayoutPage/home',
              name: 'home',
              label: '首页数据',
              icon: 'HomeOutlined',
              url: 'LayoutPage/home'
            },
            {
              path: '/LayoutPage/reusable',
              name: 'ReusableComponent',
              label: '表格增删改查',
              icon: 'ShopOutlined',
              url: 'LayoutPage/reusable'
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}

// 默认导出该变量
export default menuData
